********************************************************************************
*Table5; Columns 1 and 2
********************************************************************************
clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_blacks, clear

preserve
gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5

local deps "newbw2500   newpretermLT37 "
 foreach item in `deps' {

reg `item' plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5  i.birth_month i.year i.by i.age_cat  i.mom_birth_state   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by  , cluster(mom_birth_state)
eststo 
sum `item' if e(sample)==1
estadd scalar depvarmean = r(mean)
}
 esttab using "Table5_c1_c2.csv", append ///
se b(%9.3f) scalars ( depvarmean) keep(plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5) ///
label title(OLS_`item')  mtitles( "newbw2500"   "newpretermLT37") starlevels(* 0.1 ** .05 *** .01)   ///

eststo clear


restore

********************************************************************************
*Table5; Columns 3 and 4
********************************************************************************

clear all
set matsize 10000
set maxvar 40000
set more off
global data " "
global dir " "
use $data/estimation_sample_whites, clear

preserve
gen plus0=0
replace plus0=1 if index==0
gen plus1=0
replace plus1=1 if index==1
gen plus2=0
replace plus2=1 if index==2
gen plus3=0
replace plus3=1 if index==3
gen plus4=0
replace plus4=1 if index>=4


gen minus1=0
replace minus1=1 if index==-1
gen minus2=0
replace minus2=1 if index==-2
gen minus3=0
replace minus3=1 if index==-3
gen minus4=0
replace minus4=1 if index==-4
gen minus5=0
replace minus5=1 if index<=-5

local deps "newbw2500   newpretermLT37 "
 foreach item in `deps' {

reg `item' plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5  i.by i.age_cat  i.mom_birth_state i.birth_month i.year   i.tbo i.male   Exitexam Perstudentexpenditure Studentteacherratio Povertyrate Unemploymentrate i.division#c.by  , cluster(mom_birth_state)
eststo 
sum `item' if e(sample)==1
estadd scalar depvarmean = r(mean)
}
 esttab using "Table5_c3_c4.csv", append ///
se b(%9.3f) scalars ( depvarmean) keep(plus0 plus1 plus2 plus3 plus4   minus2 minus3 minus4 minus5) ///
label title(OLS_`item')  mtitles( "newbw2500"   "newpretermLT37") starlevels(* 0.1 ** .05 *** .01)   ///

eststo clear



restore

